#ifndef __LAMEFILE_H__
#define __LAMEFILE_H__

#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include "LString.h"

enum eFileMode
{
  FILE_READ=5,
  FILE_WRITE=6
};

class LAMEFile  
{
  HANDLE fileHandle;
  bool isOpen;
public:
	LAMEFile();
	virtual ~LAMEFile();

  bool open(const TCHAR *filename, eFileMode mode);
  void close();
  void writeInt(int i);
  int readInt();
  void writeChar(char i);
  char readChar();
  int fileSize();
  int write(void *data, int size);
  int read(void *data, int size);
  void adopt(HANDLE h) { fileHandle = h;}
  void seekBeg(int pos)
  {
    if (isOpen)
      SetFilePointer(fileHandle,pos,0,FILE_BEGIN);
  }
  void seekEnd(int pos)
  {
    if (isOpen)
      SetFilePointer(fileHandle,pos,0,FILE_END);
  }
  void seekCurrent(int pos)
  {
    if (isOpen)
      SetFilePointer(fileHandle,pos,0,FILE_CURRENT);
  }
};


#endif //__LAMEFILE_H__